package com.mstarc.app.mnfc.mstarcApiUtils;

import android.content.Context;

import mstarc_os_api.mstarc_os_api_msg;

/**
 * @author 崔健伟
 * @version V1.0
 * @Title: InitializeUtil.java
 * @Package com.mstarc.app.mnfc.mstarcApiUtils
 * @Description:
 * @date 2017/6/21 10:27
 */
public class InitializeUtil {
    private static InitializeUtil initializeUtils;
    private Context mContext;
    private boolean hasConnected;
    private boolean hasInit;
    private mstarc_os_api_msg m_api_msg;

    public static InitializeUtil getInstance(Context context) {
        if (initializeUtils == null) {
            initializeUtils = new InitializeUtil();
            initializeUtils.mContext = context;
        }
        return initializeUtils;
    }

    public mstarc_os_api_msg getMstarc_os_api_msg() {
        return new mstarc_os_api_msg(mContext) {
            @Override
            public void onServiceConnected() {
                super.onServiceConnected();
                hasConnected = true;
            }
        };
    }

    public mstarc_os_api_msg getM_api_msg() {
        if (m_api_msg == null) {
            m_api_msg = getMstarc_os_api_msg();
        }
        return m_api_msg;
    }

    public int init(mstarc_os_api_msg m_api_msg) {
        int i = m_api_msg.mstarc_sle97_init();
        hasInit = true;
        return i;
    }

    public boolean isHasInit() {
        return hasInit;
    }

    public boolean isHasConnected() {
        return hasConnected;
    }
}
